import { Form, Select } from 'antd';
import { getchannels } from 'api/list';
import { useEffect, useState } from 'react';

export default function Channel(props) {
  const [channel, setChannel] = useState([]);
  useEffect(() => {
    getChannelList();
  }, []);

  //获取频道列表
  async function getChannelList() {
    const {
      data: { channels },
    } = await getchannels();
    setChannel(channels);
  }

  return (
    <Form.Item name="channel_id" label="频道" rules={props.rules}>
      <Select style={{ width: 200 }} placeholder="请选择频道" allowClear>
        {channel.map((item) => (
          <Select.Option value={item.id} key={item.id}>
            {item.name}
          </Select.Option>
        ))}
      </Select>
    </Form.Item>
  );
}
